package com.example.sale.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.sale.True.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface ProductMapper extends BaseMapper<Product> {
    @Select("SELECT * FROM productlist WHERE name = #{name}")
    Product findByName(@Param("name") String name);
    @Select("SELECT count(*) FROM productlist WHERE type = #{type}")
    Integer  GetFruitNumber(@Param("type") String type);
    @Select("SELECT count(*) FROM productlist WHERE type = #{type}")
    Integer  GetSeafoodNumber(@Param("type") String type);
    @Select("SELECT count(*) FROM productlist WHERE type = #{type}")
    Integer  GetMeatNumber(@Param("type") String type);
    @Select("SELECT count(*) FROM productlist WHERE type = #{type}")
    Integer  GetVegetablesNumber(@Param("type") String type);
    @Select("SELECT price, name FROM productlist ORDER BY price DESC LIMIT 1")
    String GetMaxPrice();
    @Select("SELECT price, name From productlist ORDER BY Price ASC LIMIT 1")
    String GetMinPrice();
    @Select("SELECT AVG(price) FROM productlist ")
    double GetAvgPrice();
    @Select("SELECT AVG(price) FROM productlist where type = #{type}")
    double GetTypePrice(@Param("type") String type);
}
